package com.pospi.pospihold.ui.login_ui;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

import com.pospi.pospihold.R;
import com.pospi.pospihold.ui.MainActivity;
import com.pospi.pospihold.ui.base.BaseActivity;

public class SplashActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash);
        // 闪屏的核心代码
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                SharedPreferences ppp = getSharedPreferences("islogin", MODE_PRIVATE);
                boolean isIn = ppp.getBoolean("islogin", false);
                if (!isIn) {
                    startActivity(new Intent(SplashActivity.this,LoginActivity.class));
                } else {
                    startActivity(new Intent(SplashActivity.this,MainActivity.class));
                }

                SplashActivity.this.finish(); // 结束启动动画界面
            }
        }, 1500); //启动动画持续1.5秒钟
    }
}
